<template>
  <div class="pay">
    <div class="header-contant">
      <img :src="showBgc" alt>
      <div class="text">意见反馈</div>
    </div>
    <div class="main-contant"></div>
    <div class="input-contant">
      <div class="input-box">
        <div class="title">反馈内容</div>
        <textarea
          class="input"
          v-model="content"
          @blur="inputBack()"
          placeholder="请在这里写下您对充电桩的意见和建议，我们将认真对待您的反馈，并及时给您回复并答谢。"
        ></textarea>
        <div class="button-contant" @click="postData()">
          <div :class="content.length<=0 ?'button':'button1'">提交</div>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>
@import "index.less";
</style>

<script>
import { mapActions } from "vuex";

export default {
  name: "Pay",
  data() {
    return {
      showBgc: require("../../assets/suggest/pop.png"),
      content: ""
      // 后台
    };
  },
  created() {
    this.change(false);
  },
  methods: {
    ...mapActions("Home", ["change"]),
    postData() {
      if (this.content.length <= 0) {
        this.$dialog.toast({
          mes: "请输入内容",
          timeout: 1500,
          icon: "error"
        });
        return;
      }
      this.$dialog.loading.open("正在加载");
      this.$http
        .post("/advice/Create", {
          content: this.content
        })
        .then(res => {
          if (res.data.errno == 0) {
            this.$dialog.toast({
              mes: "提交成功",
              timeout: 1500,
              icon: "success"
            });
            this.content = "";
          } else {
            this.$dialog.toast({
              mes: "提交失败",
              timeout: 1500,
              icon: "error"
            });
          }
          this.$dialog.loading.close();
        });
    }
  },
  components: {}
};
</script>
